<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1,IE=9">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="LEUR DE CHINE">
	<meta name="keywords" content="china reds,china blues,cashmere,corduroy,little bag,tartans,tweeds,stars,stripes,linen,leather,tassel travel bag,tartan,accessories">
	<title>上药神象农业物联网监控系统</title>
	<!--[if lte IE 8]>
	<script>window.location.href='http://cdn.dmeng.net/upgrade-your-browser.html?referrer='+location.href;</script>
	<![endif]-->
	<script type="text/javascript" src="${basePath}/pc/lib/respond/respond.src.js"></script>
	<link href="${basePath}/pc/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
	<link href="${basePath}/pc/css/font-awesome.min.css" rel="stylesheet">
	<link href="${basePath}/pc/lib/iconfont/css/iconfont.css" rel="stylesheet">
	<link href="${basePath}/pc/css/main.css" rel="stylesheet">
	<!--[if lt IE 9]>
	<script src="${basePath}/pc/lib/bootstrap/js/html5shiv.min.js"></script>
	<script src="${basePath}/pc/lib/bootstrap/js/respond.min.js"></script>
	<![endif]-->
</head>

<body>
<div class="wrp">
	<div id="data" style="display: none;"></div>
	<nav class="navbar navbar-inverse cm_nav">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
					<span class="sr-only">navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="${basePath}/pc/user/main">
					<img src="${basePath}/pc/img/logo_white.png" class="img-responsive">
				</a>
			</div>
			<div id="navbar" class="collapse navbar-collapse">
				<ul class="nav navbar-nav mnav">
					<li>
						<a href="${basePath}/pc/user/main">监控数据</a>
					</li>
					<li class="active">
						<a href="${basePath}/function/pc/farmwork">农事记录</a>
					</li>
				</ul>
				<ul class="navbar-nav navbar-right smenu">
					<li class="wl_fnt">
						<a><i class="iconfont icon-account"></i>欢迎：<span class="username"></span></a>
					</li>
					<li class="ext_lnk">
						<a href="${basePath}/logout"><i class="iconfont icon-exit1"></i>退出</a>
					</li>
				</ul>

			</div>
			<!--/.nav-collapse -->
		</div>
	</nav>

	<div class="pgc">
		<div class="container">
			<div class="cls">
				<div class="tbar">
					<a href="javascript:history.go(-1);" class="bk_lnk"><i class="iconfont icon-left"></i></a>

					<div class="hsty_data">
						<div class="dropdown slt_eqm2">
							<a id="dLabel" role="button" data-toggle="dropdown" class="btn btn-default" data-target="#"
							   href="javascript:;">
								<span>--- 查看历史记录 ---</span><span class="caret"></span>
							</a>
							<ul class="dropdown-menu multi-level totalTime"></ul>
						</div><!--dropdown end-->
					</div><!--hsty_data end-->
					<div class="clr-b"></div>
				</div>
				<!--tbar end-->
				<div class="cnt_pd">
					<h2 class="ctit">农事记录</h2>
					<div class="frm_lst">
						<ul id="accordion" class="accordion">
							<li>
								<div class="link">播种记录
									<i class="iconfont icon-right arw_r"></i>
								</div>
								<ul class="submenu bzjl sbm_sw">
									<div class="mr"><a href="/farmwork/id/1/date/0">更多</a></div>
								</ul>
								<div class="lne"></div>
							</li>
						</ul>
					</div><!--ept_menu end-->
				</div>
				<!--cnt_pd end-->
			</div>
			<!--cls end-->
		</div>
	</div>
	<!--pgc end-->
	<footer class="ftr">Copyright<span class="cpy">&copy;</span>2017 上海上药神象健康药业有限公司</footer>
</div>
<!--wrp end-->
<script src="${basePath}/pc/lib/jquery/jquery.min.js"></script>
<script src="${basePath}/pc/lib/bootstrap/js/bootstrap.min.js"></script>
<script src="${basePath}/common/js/common.js"></script>
<script src="${basePath}/common/js/ajax.js"></script>
<script src="${basePath}/common/js/form.js"></script>
<script src="${basePath}/pc/js/custom.js"></script>
<script>
	$(function () {
        AsyncGet("${basePath}/pc/user/getUserRole", null, function (value) {
            $(".username").text(value.data.username);
            if (value.data.userType == 3) {
                $(".totalTime").append('<li style="cursor:pointer;" time="1" class="active"><a>一天数据</a></li>');
                $(".totalTime").append('<li style="cursor:pointer;" time="7"><a>一周数据</a></li>');
                $(".totalTime").append('<li style="cursor:pointer;" time="30"><a>一月数据</a></li>');
            }else if (value.data.userType == 2) {
                $(".totalTime").append('<li style="cursor:pointer;" time="1" class="active"><a>一天数据</a></li>');
                $(".totalTime").append('<li style="cursor:pointer;" time="7"><a>一周数据</a></li>');
            }else{
                $(".totalTime").append('<li style="cursor:pointer;" time="1" class="active"><a>一天数据</a></li>');
            }
        })
		AsyncGet("${basePath}/pc/user/getFarmType",null,function (value) {
		    $("#accordion").empty();
			for(var i=0;i<value.data.length;i++){
			    var name=value.data[i].name;
			    var id=value.data[i].id;
			    var li=$("<li></li>");
			    var linkDiv=$("<div class='link'>"+name+"<i class='iconfont icon-right arw_r'></i></div>");
			    var submenuUl=$("<ul class='submenu'><div class='mr'><a style='cursor:pointer' id='"+id+"'>更多</a></div></ul>");
			    var lneDiv=$("<div class='lne'></div>");

			    li.append(linkDiv).append(submenuUl).append(lneDiv);
                $("#accordion").append(li);
			}
            new Accordion($('#accordion'), false);
        })
		
		$("#accordion").on("click",".mr a",function () {
		    $("#accordion li .mr").show();
            $("#accordion li ul li").remove();
			$(this).parent().hide();
			var ul=$(this).parents(".submenu");
			var param={farmTypeId:$(this).attr("id"),totalTime:$(".totalTime li.active").attr("time")};
			AsyncGet("${basePath}/pc/user/getFarmRecord",param,function (value) {
				for(var i=0;i<value.data.length;i++){
				    ul.append("<li>"+value.data[i].record+"</li>");
				}
            })
        })

        $(".totalTime").on("click","li",function () {
            $(this).addClass("active").siblings().removeClass("active");
            $(this).parent().prev().find("span:first").text($(this).find("a").text());

            var ul=$("#accordion li.open .submenu");
            ul.find("li").remove();
            var param={farmTypeId:ul.find("a").attr("id"),totalTime:$(".totalTime li.active").attr("time")};
            AsyncGet("${basePath}/pc/user/getFarmRecord",param,function (value) {
                for(var i=0;i<value.data.length;i++){
                    ul.append("<li>"+value.data[i].record+"</li>");
                }
            })
        })
    })
</script>
</body>
</html>